<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/', function () {
    return view('welcome');
});
Route::post('photo', 'PhotoController@store');


Auth::routes();
Route::get('/home', 'HomeController@index')->name('home');
//写一个用于显示后台登录界面的路由
Route::get('/login','Admin\LoginController@login')->name('login');
//定义一个路由，用于检查用于登录信息
Route::post('/checkLogin','Admin\LoginController@checkLogin')->name('checkLogin');

/*
 * 给后台部分路由分组中定义的所有路由分配是否登录isLogin中间件
 * */
Route::namespace('Admin')->middleware(['isLogin'])->group(function () {
    //后台首页
    Route::get('/index','IndexController@index');
    //退出登录
    Route::get('/logout','LoginController@logout')->name('logout');
    //项目管理
    Route::resource('project','ProjectController');
    Route::get('createProject','ProjectController@createProject')->name('createProject');
    Route::post('saveProject','ProjectController@saveProject')->name('saveProject');
    Route::get('editProject/{projectId}','ProjectController@editProject')->name('editProject');
    Route::post('updateProject','ProjectController@updateProject')->name('updateProject');
    Route::post('deleteProject','ProjectController@deleteProject')->name('deleteProject');


    //前期调查
    Route::resource('survey','SurveyController');
    Route::get('/editSurvey/{surveyId}','SurveyController@editSurvey')->name('editSurvey');
    Route::post('/updateSurvey','SurveyController@updateSurvey')->name('updateSurvey');
    Route::post('/deleteSurvey','SurveyController@deleteSurvey')->name('deleteSurvey');
    //房屋详情
    Route::get('/housesIndex','HousesController@housesIndex')->name('housesIndex');
    Route::get('/newHouses','HousesController@newHouses')->name('newHouses');
    Route::post('/saveHouses','HousesController@saveHouses')->name('saveHouses');
    Route::get('/editHouses/{housesId}','HousesController@editHouses')->name('editHouses');
    Route::post('/updateHouses','HousesController@updateHouses')->name('updateHouses');
    Route::post('/deleteHouses','HousesController@deleteHouses')->name('deleteHouses');
    Route::post('/sendToContract','HousesController@sendToContract')->name('sendToContract');
    Route::get('/housesDetail','HousesController@housesDetail')->name('housesDetail');





    //写一个用于提示操作成功页面的路由
    Route::view('/success','Admin\success')->name('success');



    // 合同签订
    Route::PATCH('contract/change_on', 'ContractController@change_on')->name('contract.change_on');
    Route::PATCH('contract/is_send', 'ContractController@is_send')->name('contract.is_send');
    Route::post('contract/show_img', 'ContractController@show_img')->name('contract.show_img');
    Route::PATCH('contract/is_send_pay', 'ContractController@is_send_pay')->name('contract.is_send_pay');
    Route::PATCH('contract/upload_img', 'ContractController@upload_img')->name('contract.upload_img');
    Route::get('/editContract/{contractId}','ContractController@editContract')->name('editContract');
    Route::post('/updateContract','ContractController@updateContract')->name('updateContract');
    Route::get('contract/detail', 'ContractController@detail')->name('contract.detail');
    Route::resource('contract', 'ContractController', ['only' => ['index'] ]);

    // 审计管理
    Route::PATCH('audit/change_on', 'AuditController@change_on')->name('audit.change_on');
    Route::post('audit/show_img', 'AuditController@show_img')->name('audit.show_img');
    Route::resource('audit', 'AuditController', ['only' => ['index'] ]);

    // 支付管理
    Route::PATCH('pay/change_on', 'PayController@change_on')->name('contract.change_on');
    Route::get('/editPay/{payId}','PayController@editPay')->name('editPay');
    Route::post('/updatePay','PayController@updatePay')->name('updatePay');
    Route::resource('pay', 'PayController', ['only' => ['index', 'edit'] ]);

    //房源管理
    Route::get('housingIndex','HousingResourceController@housingIndex')->name('housingIndex');
    Route::get('createHousing','HousingResourceController@createHousing')->name('createHousing');
    Route::post('saveHousing','HousingResourceController@saveHousing')->name('saveHousing');
    Route::get('editHousing/{housing_id}','HousingResourceController@editHousing')->name('editHousing');
    Route::post('updateHousing','HousingResourceController@updateHousing')->name('updateHousing');
    Route::post('sendHousing','HousingResourceController@sendHousing')->name('sendHousing');

    //用户管理
    Route::get('userList','UserController@userList')->name('userList');
    Route::get('createUser','UserController@createUser')->name('createUser');
    Route::post('saveUser','UserController@saveUser')->name('saveUser');
    Route::get('editUser/{userId}','UserController@editUser')->name('editUser');
    Route::post('updateUser','UserController@updateUser')->name('updateUser');
    Route::post('deleteUser','UserController@deleteUser')->name('deleteUser');
    Route::get('addRole/{userId}','UserController@addRole')->name('addRole');
    Route::post('checkRole','UserController@checkRole')->name('checkRole');

    //角色管理
    Route::get('roleList','RoleController@roleList')->name('roleList');
    Route::get('createRole','RoleController@createRole')->name('createRole');
    Route::post('saveRole','RoleController@saveRole')->name('saveRole');
    Route::get('editRole/{roleId}','RoleController@editRole')->name('editRole');
    Route::post('updateRole','RoleController@updateRole')->name('updateRole');
    Route::post('deleteRole','RoleController@deleteRole')->name('deleteRole');
    Route::get('addPermission/{roleId}','RoleController@addPermission')->name('addPermission');
    Route::post('checkPermission','RoleController@checkPermission')->name('checkPermission');


    //权限管理
    Route::get('permissionList','PermissionController@permissionList')->name('permissionList');
    Route::get('createPermission','PermissionController@createPermission')->name('createPermission');
    Route::post('savePermission','PermissionController@savePermission')->name('savePermission');
    Route::get('editPermission/{permissionId}','PermissionController@editPermission')->name('editPermission');
    Route::post('updatePermission','PermissionController@updatePermission')->name('updatePermission');
    Route::post('deletePermission','PermissionController@deletePermission')->name('deletePermission');


});








